namespace Test
import Grawlix

struct A:
	
	val as int
	
	[Equality]
	private def Equality(rhs as A):
		return val == rhs.val


a = A()
b as System.IEquatable[of A] = a
c as object = a
# Cannot have a value-typed null
#x as A = null
y as System.IEquatable[of A] = null
z as object = null

assert     a.Equals(a)
assert     a.Equals(b)
assert     a.Equals(c)
#assert not a.Equals(x) # no x
#assert not a.Equals(y) # See BOO-1061
assert not a.Equals(z)
assert not a.Equals(null)
assert     a == a
assert     a == b
assert     a == c
#assert not a == x  # no x
assert not a == y
assert not a == z
#assert not a == null # can't convert null to A
assert not a != a
assert not a != b
assert not a != c
#assert     a != x  # no x
#assert     a != y # See BOO-1061
assert     a != z
#assert     a != null # can't convert null to A

assert     b.Equals(a)
assert     b.Equals(b)
assert     b.Equals(c)
#assert not b.Equals(x) # no x
#assert not b.Equals(y) # See BOO-1061
assert not b.Equals(z)
assert not b.Equals(null)
assert     b == a
assert     b == b
assert     b == c
#assert not b == x # no x
#assert not b == y # See BOO-1061
assert not b == z
assert not b == null
assert not b != a
assert not b != b
assert not b != c
#assert     b != x # no x
assert     b != y
assert     b != z
assert     b != null

assert     c.Equals(a)
#assert     c.Equals(b) # no object.Equals(IEquatable)
assert     c.Equals(c)
#assert not c.Equals(x) # no x
#assert not c.Equals(y) # no object.Equals(IEquatable)
assert not c.Equals(z)
assert not c.Equals(null)
assert     c == a
assert     c == b
assert     c == c
#assert not c == x # no x
assert not c == y
assert not c == z
assert not c == null
assert not c != a
assert not c != b
assert not c != c
#assert     c != x # no x
assert     c != y
assert     c != z
assert     c != null

# No x
#assert not x.Equals(a)
#assert not x.Equals(b)
#assert not x.Equals(c)
#assert     x.Equals(x)
#assert     x.Equals(y)
#assert     x.Equals(z)
#assert     x.Equals(null)
#assert not x == a
#assert not x == b
#assert not x == c
#assert     x == x
#assert     x == y
#assert     x == z
#assert     x == null
#assert     x != a
#assert     x != b
#assert     x != c
#assert not x != x
#assert not x != y
#assert not x != z
#assert not x != null

# Cannot call method on null
#assert not y.Equals(a)
#assert not y.Equals(b)
#assert not y.Equals(c)
#assert     y.Equals(x)
#assert     y.Equals(y)
#assert     y.Equals(z)
#assert     y.Equals(null)
assert not y == a
assert not y == b
assert not y == c
#assert     y == x # no x
assert     y == y
assert     y == z
assert     y == null
assert     y != a
assert     y != b
assert     y != c
#assert not y != x # no x
assert not y != y
assert not y != z
assert not y != null

# Cannot call method on null
#assert not z.Equals(a)
#assert not z.Equals(b)
#assert not z.Equals(c)
#assert     z.Equals(x)
#assert     z.Equals(y)
#assert     z.Equals(z)
#assert     z.Equals(null)
assert not z == a
assert not z == b
assert not z == c
#assert     z == x # no x
assert     z == y
assert     z == z
assert     z == null
assert     z != a
assert     z != b
assert     z != c
#assert not z != x # no x
assert not z != y
assert not z != z
assert not z != null

# Cannot call method on null
#assert not null.Equals(a)
#assert not null.Equals(b)
#assert not null.Equals(c)
#assert     null.Equals(x)
#assert     null.Equals(y)
#assert     null.Equals(z)
#assert     null.Equals(null)
#assert not null == a # can't convert null to A
assert not null == b
assert not null == c
#assert     null == x # no x
assert     null == y
assert     null == z
assert     null == null
#assert     null != a # can't convert null to A
assert     null != b
assert     null != c
#assert not null != x # no x
assert not null != y
assert not null != z
assert not null != null

